package cn.john.hrm.mapper;

import cn.john.hrm.domain.Employee;
import cn.john.hrm.domain.UserContextInfo;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author john
 * @since 2021-06-17
 */
public interface EmployeeMapper extends BaseMapper<Employee> {
    @Select("SELECT\n" +
            "\tt1.id userId,\n" +
            "\tt1.username userName,\n" +
            "\tt2.id tenantId,\n" +
            "\tt2.company_name tenantName \n" +
            "FROM\n" +
            "\tt_employee t1\n" +
            "\tLEFT JOIN t_tenant t2 ON t1.id = t2.admin_id \n" +
            "WHERE\n" +
            "\tt1.login_id = #{id}")
    UserContextInfo getUserInfo(Long loginId);
}
